﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////


#include "GcmpInternalCommandNames.h"
#include "CmdAvailibilityUtils.h"
#include "CommandParameters.h"
#include "ComponentEditorGnufUICmdRegisterHelper.h"
#include "ComponentEditorGnufUICommandIds.h"
#include "ComponentEditorConfigTool.h"
#include "FamilyCmdAvailibilityUtils.h"
#include "FilePath.h"
#include "GbmpFileSystem.h"
#include "NewLocalFamilyDocumentCommand.h"
#include "UiCommonDialog.h"
#include "IFamilyDataStandardService.h"
#include "FamilyNewFileFromDlg.h"
#include "EnableCompileWarning_The_LAST_IncludeInCpp.h"

using namespace gcmp;
using namespace gfam;

REGISTER_FAM_GNUF_UI_COMMAND(NewLocalFamilyDocumentFromGapTemplateCommand)
REGISTER_FAM_GNUF_UI_COMMAND(NewLocalFamilyDocumentFromGstTemplateCommand)
REGISTER_FAM_GNUF_UI_COMMAND(NewLocalFamilyDocumentFromGMepTemplateCommand)
REGISTER_FAM_GNUF_UI_COMMAND(NewLocalFamilyDocumentFromGroadTemplateCommand)
REGISTER_FAM_GNUF_UI_COMMAND(NewLocalFamilyDocumentFromBimmakeTemplateCommand)
REGISTER_FAM_GNUF_UI_COMMAND(NewLocalFamilyDocumentFromDecoTemplateCommand)
REGISTER_FAM_GNUF_UI_COMMAND(NewLocalFamilyDocumentCommand)

// 新建Gap构件
NewLocalFamilyDocumentFromGapTemplateCommand::NewLocalFamilyDocumentFromGapTemplateCommand()
    : CommandBase(NEW_LOCAL_FAMILY_DOCUMENT_FROM_GAP_TEMPLATE_COMMAND)
{}

bool NewLocalFamilyDocumentFromGapTemplateCommand::IsEnabled() const
{
    return !CmdAvailibilityUtils::IsInAnimationEnvironment() && (!CmdAvailibilityUtils::IsInEditMode() || FamilyCmdAvailibilityUtils::IsInProfileEditMode());
}

bool NewLocalFamilyDocumentFromGapTemplateCommand::IsVisible() const
{
    return !CmdAvailibilityUtils::IsInAnimationEnvironment();
}

gcmp::OwnerPtr<gcmp::IAction> NewLocalFamilyDocumentFromGapTemplateCommand::ExecuteCommand(const gcmp::CommandParameters& cmdParams)
{
    FamilyNewFileFromDlg dlg;
    if (dlg.exec() != QDialog::Accepted)
        return nullptr;

    CommandParameters newCmdParams;
    NewFileFromType type = dlg.GetFromType();
    if (NewFileFromType::FromLocal == type)
    {
        // 获取路径
        std::wstring productConfigPath = ComponentEditorConfigTool::GetSpecifyProductConfigPath(L"AppGarch");
        if (productConfigPath.empty())
        {
            UiCommonDialog::ShowMessageBox(GBMP_TR(L"文件夹不存在"), GBMP_TR(L"未找到模板文件夹！"), (int)UiCommonDialog::ButtonType::OK);
            return false;
        }

        std::wstring productFamilyParametersFilePath = FilePath::Combine(productConfigPath, L"Templates");
        FileInfo info(productFamilyParametersFilePath);
        if (!info.Exists())
        {
            UiCommonDialog::ShowMessageBox(GBMP_TR(L"文件夹不存在"), GBMP_TR(L"未找到模板文件夹！"), (int)UiCommonDialog::ButtonType::OK);
            productFamilyParametersFilePath = FileSystem::GetExeDirPath();
        }

        newCmdParams[L"TemplateFilePath"] = productFamilyParametersFilePath;
        gcmp::ICommandManager* pCommandManager = gcmp::ICommandManager::Get();
        DBG_WARN_AND_RETURN_NULLPTR_UNLESS(pCommandManager, L"pCommandManager为空指针", L"paramodel", L"2024-02-20");
        pCommandManager->SendCommand(ID_CMD_COMPONENT_EDITOR_NEW_FILE, newCmdParams);
    }
    else if (NewFileFromType::FromCloud == type)
    {
        if (IFamilyDataStandardService::GlobalInstance())
        {
            newCmdParams[L"SoftwareCode"] = L"AppGarch";
            std::wstring version = IFamilyDataStandardService::GlobalInstance()->GetSoftwareVersionBySoftwareCode(L"AppGarch");
            if (!version.empty())
            {
                std::vector<std::wstring> versionParts = StringUtil::SplitString(version, L".");
                if (versionParts.size() > 1)
                {
                    std::wstring shortVersion = versionParts[0] + L"." + versionParts[1];
                    newCmdParams[L"SoftwareVersion"] = shortVersion;
                    gcmp::ICommandManager* pCommandManager = gcmp::ICommandManager::Get();
                    DBG_WARN_AND_RETURN_NULLPTR_UNLESS(pCommandManager, L"pCommandManager为空指针", L"paramodel", L"2024-02-20");
                    pCommandManager->SendCommand(ID_CMD_COMPONENT_EDITOR_NEW_FILE_FROM_CLOUD, newCmdParams);
                }
            }
        }
    }

    return nullptr;
}

// 新建Gst构件
NewLocalFamilyDocumentFromGstTemplateCommand::NewLocalFamilyDocumentFromGstTemplateCommand()
    : CommandBase(NEW_LOCAL_FAMILY_DOCUMENT_FROM_GST_TEMPLATE_COMMAND)
{}

bool NewLocalFamilyDocumentFromGstTemplateCommand::IsEnabled() const
{
    return !CmdAvailibilityUtils::IsInAnimationEnvironment() && (!CmdAvailibilityUtils::IsInEditMode() || FamilyCmdAvailibilityUtils::IsInProfileEditMode());
}

bool NewLocalFamilyDocumentFromGstTemplateCommand::IsVisible() const
{
    return !CmdAvailibilityUtils::IsInAnimationEnvironment();
}

gcmp::OwnerPtr<gcmp::IAction> NewLocalFamilyDocumentFromGstTemplateCommand::ExecuteCommand(const gcmp::CommandParameters& cmdParams)
{
    // 获取路径
    std::wstring productConfigPath = ComponentEditorConfigTool::GetSpecifyProductConfigPath(L"AppGstr");
    if (productConfigPath.empty())
    {
        UiCommonDialog::ShowMessageBox(GBMP_TR(L"文件夹不存在"), GBMP_TR(L"未找到模板文件夹！"), (int)UiCommonDialog::ButtonType::OK);
        return false;
    }

    std::wstring productFamilyParametersFilePath = FilePath::Combine(productConfigPath, L"Templates");
    FileInfo info(productFamilyParametersFilePath);
    if (!info.Exists())
    {
        UiCommonDialog::ShowMessageBox(GBMP_TR(L"文件夹不存在"), GBMP_TR(L"未找到模板文件夹！"), (int)UiCommonDialog::ButtonType::OK);
        productFamilyParametersFilePath = FileSystem::GetExeDirPath();
    }

    CommandParameters newCmdParams;
    newCmdParams[L"TemplateFilePath"] = productFamilyParametersFilePath;
    gcmp::ICommandManager* pCommandManager = gcmp::ICommandManager::Get();
    DBG_WARN_AND_RETURN_NULLPTR_UNLESS(pCommandManager, L"pCommandManager为空指针", L"paramodel", L"2024-02-20");
    pCommandManager->SendCommand(ID_CMD_COMPONENT_EDITOR_NEW_FILE, newCmdParams);

    return nullptr;
}

// 新建GMep构件
NewLocalFamilyDocumentFromGMepTemplateCommand::NewLocalFamilyDocumentFromGMepTemplateCommand()
    : CommandBase(NEW_LOCAL_FAMILY_DOCUMENT_FROM_GMEP_TEMPLATE_COMMAND)
{}

bool NewLocalFamilyDocumentFromGMepTemplateCommand::IsEnabled() const
{
    return !CmdAvailibilityUtils::IsInAnimationEnvironment() && (!CmdAvailibilityUtils::IsInEditMode() || FamilyCmdAvailibilityUtils::IsInProfileEditMode());
}

bool NewLocalFamilyDocumentFromGMepTemplateCommand::IsVisible() const
{
    return !CmdAvailibilityUtils::IsInAnimationEnvironment();
}

gcmp::OwnerPtr<gcmp::IAction> NewLocalFamilyDocumentFromGMepTemplateCommand::ExecuteCommand(const gcmp::CommandParameters& cmdParams)
{
    FamilyNewFileFromDlg dlg;
    if (dlg.exec() != QDialog::Accepted)
        return nullptr;

    NewFileFromType type = dlg.GetFromType();
    if (NewFileFromType::FromLocal == type)
    {
        // 获取路径
        std::wstring productConfigPath = ComponentEditorConfigTool::GetSpecifyProductConfigPath(L"AppGmep");
        if (productConfigPath.empty())
        {
            UiCommonDialog::ShowMessageBox(GBMP_TR(L"文件夹不存在"), GBMP_TR(L"未找到模板文件夹！"), (int)UiCommonDialog::ButtonType::OK);
            return false;
        }

        std::wstring productFamilyParametersFilePath = FilePath::Combine(productConfigPath, L"Templates");
        FileInfo info(productFamilyParametersFilePath);
        if (!info.Exists())
        {
            UiCommonDialog::ShowMessageBox(GBMP_TR(L"文件夹不存在"), GBMP_TR(L"未找到模板文件夹！"), (int)UiCommonDialog::ButtonType::OK);
            productFamilyParametersFilePath = FileSystem::GetExeDirPath();
        }

        CommandParameters newCmdParams;
        newCmdParams[L"TemplateFilePath"] = productFamilyParametersFilePath;
        gcmp::ICommandManager* pCommandManager = gcmp::ICommandManager::Get();
        DBG_WARN_AND_RETURN_NULLPTR_UNLESS(pCommandManager, L"pCommandManager为空指针", L"paramodel", L"2024-02-20");
        pCommandManager->SendCommand(ID_CMD_COMPONENT_EDITOR_NEW_FILE, newCmdParams);
    }
    else if (NewFileFromType::FromCloud == type)
    {
        if (IFamilyDataStandardService::GlobalInstance())
        {
            CommandParameters newCmdParams;
            newCmdParams[L"SoftwareCode"] = L"AppGmep";
            std::wstring version = IFamilyDataStandardService::GlobalInstance()->GetSoftwareVersionBySoftwareCode(L"AppGmep");
            if (!version.empty())
            {
                std::vector<std::wstring> versionParts = StringUtil::SplitString(version, L".");
                if (versionParts.size() > 1)
                {
                    std::wstring shortVersion = versionParts[0] + L"." + versionParts[1];
                    newCmdParams[L"SoftwareVersion"] = shortVersion;
                    gcmp::ICommandManager* pCommandManager = gcmp::ICommandManager::Get();
                    DBG_WARN_AND_RETURN_NULLPTR_UNLESS(pCommandManager, L"pCommandManager为空指针", L"paramodel", L"2024-02-20");
                    pCommandManager->SendCommand(ID_CMD_COMPONENT_EDITOR_NEW_FILE_FROM_CLOUD, newCmdParams);
                }
            }
        }
    }

    return nullptr;
}

// 新建Groad构件
NewLocalFamilyDocumentFromGroadTemplateCommand::NewLocalFamilyDocumentFromGroadTemplateCommand()
    : CommandBase(NEW_LOCAL_FAMILY_DOCUMENT_FROM_GROAD_TEMPLATE_COMMAND)
{}

bool NewLocalFamilyDocumentFromGroadTemplateCommand::IsEnabled() const
{
    return !CmdAvailibilityUtils::IsInAnimationEnvironment() && (!CmdAvailibilityUtils::IsInEditMode() || FamilyCmdAvailibilityUtils::IsInProfileEditMode());
}

bool NewLocalFamilyDocumentFromGroadTemplateCommand::IsVisible() const
{
    return !CmdAvailibilityUtils::IsInAnimationEnvironment();
}

gcmp::OwnerPtr<gcmp::IAction> NewLocalFamilyDocumentFromGroadTemplateCommand::ExecuteCommand(const gcmp::CommandParameters& cmdParams)
{
    // 获取路径
    std::wstring productConfigPath = ComponentEditorConfigTool::GetSpecifyProductConfigPath(L"AppGroad");
    if (productConfigPath.empty())
    {
        UiCommonDialog::ShowMessageBox(GBMP_TR(L"文件夹不存在"), GBMP_TR(L"未找到模板文件夹！"), (int)UiCommonDialog::ButtonType::OK);
        return false;
    }

    std::wstring productFamilyParametersFilePath = FilePath::Combine(productConfigPath, L"Templates");
    FileInfo info(productFamilyParametersFilePath);
    if (!info.Exists())
    {
        UiCommonDialog::ShowMessageBox(GBMP_TR(L"文件夹不存在"), GBMP_TR(L"未找到模板文件夹！"), (int)UiCommonDialog::ButtonType::OK);
        productFamilyParametersFilePath = FileSystem::GetExeDirPath();
    }

    CommandParameters newCmdParams;
    newCmdParams[L"TemplateFilePath"] = productFamilyParametersFilePath;
    gcmp::ICommandManager* pCommandManager = gcmp::ICommandManager::Get();
    DBG_WARN_AND_RETURN_NULLPTR_UNLESS(pCommandManager, L"pCommandManager为空指针", L"paramodel", L"2024-02-20");
    pCommandManager->SendCommand(ID_CMD_COMPONENT_EDITOR_NEW_FILE, newCmdParams);

    return nullptr;
}

// 新建BIMMAKE构件
NewLocalFamilyDocumentFromBimmakeTemplateCommand::NewLocalFamilyDocumentFromBimmakeTemplateCommand()
    : CommandBase(NEW_LOCAL_FAMILY_DOCUMENT_FROM_BIMMAKE_TEMPLATE_COMMAND)
{}

bool NewLocalFamilyDocumentFromBimmakeTemplateCommand::IsEnabled() const
{
    return !CmdAvailibilityUtils::IsInAnimationEnvironment() && (!CmdAvailibilityUtils::IsInEditMode() || FamilyCmdAvailibilityUtils::IsInProfileEditMode());
}

bool NewLocalFamilyDocumentFromBimmakeTemplateCommand::IsVisible() const
{
    return !CmdAvailibilityUtils::IsInAnimationEnvironment();
}

gcmp::OwnerPtr<gcmp::IAction> NewLocalFamilyDocumentFromBimmakeTemplateCommand::ExecuteCommand(const gcmp::CommandParameters& cmdParams)
{
    std::wstring productProfessional = ComponentEditorConfigTool::GetCurrentProductProfessional();
    if (productProfessional == L"AppBimmake")
    {
        // 获取路径
        std::wstring configRootPath = ComponentEditorConfigTool::GetAppBimmakeTemplateRootPath();
        if (configRootPath.empty())
        {
            UiCommonDialog::ShowMessageBox(GBMP_TR(L"文件夹不存在"), GBMP_TR(L"未找到模板文件夹！"), (int)UiCommonDialog::ButtonType::OK);
            return nullptr;
        }

        std::wstring productFamilyParametersFilePath = FilePath::Combine(configRootPath, L"AppBimmake", L"Templates"); // 当前产品配置路径
        FileInfo info(productFamilyParametersFilePath);
        if (!info.Exists())
        {
            UiCommonDialog::ShowMessageBox(GBMP_TR(L"文件夹不存在"), GBMP_TR(L"未找到模板文件夹！"), (int)UiCommonDialog::ButtonType::OK);
            return nullptr;
        }

        CommandParameters newCmdParams;
        newCmdParams[L"TemplateFilePath"] = productFamilyParametersFilePath;
        gcmp::ICommandManager* pCommandManager = gcmp::ICommandManager::Get();
        DBG_WARN_AND_RETURN_NULLPTR_UNLESS(pCommandManager, L"pCommandManager为空指针", L"paramodel", L"2024-02-20");
        pCommandManager->SendCommand(ID_CMD_COMPONENT_EDITOR_NEW_FILE, newCmdParams);

        return nullptr;
    }
    else
    {
        // 获取路径
        std::wstring productConfigPath = ComponentEditorConfigTool::GetSpecifyProductConfigPath(L"AppBimmake");
        if (productConfigPath.empty())
        {
            UiCommonDialog::ShowMessageBox(GBMP_TR(L"文件夹不存在"), GBMP_TR(L"未找到模板文件夹！"), (int)UiCommonDialog::ButtonType::OK);
            return nullptr;
        }

        std::wstring productFamilyParametersFilePath = FilePath::Combine(productConfigPath, L"Templates");
        FileInfo info(productFamilyParametersFilePath);
        if (!info.Exists())
        {
            UiCommonDialog::ShowMessageBox(GBMP_TR(L"文件夹不存在"), GBMP_TR(L"未找到模板文件夹！"), (int)UiCommonDialog::ButtonType::OK);
            productFamilyParametersFilePath = FileSystem::GetExeDirPath();
        }

        CommandParameters newCmdParams;
        newCmdParams[L"TemplateFilePath"] = productFamilyParametersFilePath;
        gcmp::ICommandManager* pCommandManager = gcmp::ICommandManager::Get();
        DBG_WARN_AND_RETURN_NULLPTR_UNLESS(pCommandManager, L"pCommandManager为空指针", L"paramodel", L"2024-02-20");
        pCommandManager->SendCommand(ID_CMD_COMPONENT_EDITOR_NEW_FILE, newCmdParams);

        return nullptr;
    }
}

// 新建Deco构件
NewLocalFamilyDocumentFromDecoTemplateCommand::NewLocalFamilyDocumentFromDecoTemplateCommand()
    : CommandBase(NEW_LOCAL_FAMILY_DOCUMENT_FROM_DECO_TEMPLATE_COMMAND)
{}

bool NewLocalFamilyDocumentFromDecoTemplateCommand::IsEnabled() const
{
    return !CmdAvailibilityUtils::IsInAnimationEnvironment() && (!CmdAvailibilityUtils::IsInEditMode() || FamilyCmdAvailibilityUtils::IsInProfileEditMode());
}

bool NewLocalFamilyDocumentFromDecoTemplateCommand::IsVisible() const
{
    return !CmdAvailibilityUtils::IsInAnimationEnvironment();
}

gcmp::OwnerPtr<gcmp::IAction> NewLocalFamilyDocumentFromDecoTemplateCommand::ExecuteCommand(const gcmp::CommandParameters& cmdParams)
{
    // 获取路径
    std::wstring productConfigPath = ComponentEditorConfigTool::GetSpecifyProductConfigPath(L"AppDeco");
    if (productConfigPath.empty())
    {
        UiCommonDialog::ShowMessageBox(GBMP_TR(L"文件夹不存在"), GBMP_TR(L"未找到模板文件夹！"), (int)UiCommonDialog::ButtonType::OK);
        return false;
    }

    std::wstring productFamilyParametersFilePath = FilePath::Combine(productConfigPath, L"Templates");
    FileInfo info(productFamilyParametersFilePath);
    if (!info.Exists())
    {
        UiCommonDialog::ShowMessageBox(GBMP_TR(L"文件夹不存在"), GBMP_TR(L"未找到模板文件夹！"), (int)UiCommonDialog::ButtonType::OK);
        productFamilyParametersFilePath = FileSystem::GetExeDirPath();
    }

    CommandParameters newCmdParams;
    newCmdParams[L"TemplateFilePath"] = productFamilyParametersFilePath;
    gcmp::ICommandManager* pCommandManager = gcmp::ICommandManager::Get();
    DBG_WARN_AND_RETURN_NULLPTR_UNLESS(pCommandManager, L"pCommandManager为空指针", L"paramodel", L"2024-02-20");
    pCommandManager->SendCommand(ID_CMD_COMPONENT_EDITOR_NEW_FILE, newCmdParams);

    return nullptr;
}

// 新建其他构件
NewLocalFamilyDocumentCommand::NewLocalFamilyDocumentCommand()
    : CommandBase(NEW_LOCAL_FAMILY_DOCUMENT_COMMAND)
{}

bool NewLocalFamilyDocumentCommand::IsEnabled() const
{
    return !CmdAvailibilityUtils::IsInAnimationEnvironment() && (!CmdAvailibilityUtils::IsInEditMode() || FamilyCmdAvailibilityUtils::IsInProfileEditMode());
}

bool NewLocalFamilyDocumentCommand::IsVisible() const
{
    return !CmdAvailibilityUtils::IsInAnimationEnvironment();
}

gcmp::OwnerPtr<gcmp::IAction> NewLocalFamilyDocumentCommand::ExecuteCommand(const gcmp::CommandParameters& cmdParams)
{
    std::wstring productProfessional = ComponentEditorConfigTool::GetCurrentProductProfessional();
    if (productProfessional == L"AppBimmake")
    {
        // 获取路径
        std::wstring configRootPath = ComponentEditorConfigTool::GetAppBimmakeTemplateRootPath();
        if (configRootPath.empty())
        {
            UiCommonDialog::ShowMessageBox(GBMP_TR(L"文件夹不存在"), GBMP_TR(L"未找到模板文件夹！"), (int)UiCommonDialog::ButtonType::OK);
            return nullptr;
        }

        std::wstring productFamilyParametersFilePath = FilePath::Combine(configRootPath, L"AppParamodel", L"Templates"); // 当前产品配置路径
        FileInfo info(productFamilyParametersFilePath);
        if (!info.Exists())
        {
            UiCommonDialog::ShowMessageBox(GBMP_TR(L"文件夹不存在"), GBMP_TR(L"未找到模板文件夹！"), (int)UiCommonDialog::ButtonType::OK);
            return nullptr;
        }

        CommandParameters newCmdParams;
        newCmdParams[L"TemplateFilePath"] = productFamilyParametersFilePath;
        auto iter = cmdParams.find(L"ProfileFamily");
        if (iter != cmdParams.end())
        {
            newCmdParams[iter->first] = iter->second;
        }

        gcmp::ICommandManager* pCommandManager = gcmp::ICommandManager::Get();
        DBG_WARN_AND_RETURN_NULLPTR_UNLESS(pCommandManager, L"pCommandManager为空指针", L"paramodel", L"2024-02-20");
        pCommandManager->SendCommand(ID_CMD_COMPONENT_EDITOR_NEW_FILE, newCmdParams);

        return nullptr;
    }
    else
    {
        // 获取路径
        std::wstring productConfigPath = ComponentEditorConfigTool::GetSpecifyProductConfigPath(L"AppParamodel");
        if (productConfigPath.empty())
        {
            UiCommonDialog::ShowMessageBox(GBMP_TR(L"文件夹不存在"), GBMP_TR(L"未找到模板文件夹！"), (int)UiCommonDialog::ButtonType::OK);
            return nullptr;
        }

        std::wstring productFamilyParametersFilePath = FilePath::Combine(productConfigPath, L"Templates");
        FileInfo info(productFamilyParametersFilePath);
        if (!info.Exists())
        {
            UiCommonDialog::ShowMessageBox(GBMP_TR(L"文件夹不存在"), GBMP_TR(L"未找到模板文件夹！"), (int)UiCommonDialog::ButtonType::OK);
            productFamilyParametersFilePath = FileSystem::GetExeDirPath();
        }

        CommandParameters newCmdParams;
        newCmdParams[L"TemplateFilePath"] = productFamilyParametersFilePath;
        auto iter = cmdParams.find(L"ProfileFamily");
        if (iter != cmdParams.end())
        {
            newCmdParams[iter->first] = iter->second;
        }

        gcmp::ICommandManager* pCommandManager = gcmp::ICommandManager::Get();
        DBG_WARN_AND_RETURN_NULLPTR_UNLESS(pCommandManager, L"pCommandManager为空指针", L"paramodel", L"2024-02-20")
        pCommandManager->SendCommand(ID_CMD_COMPONENT_EDITOR_NEW_FILE, newCmdParams);

        return nullptr;
    }
}